<?php
class Accordion{
	var $autoHeight = true;
	var $id;
	var $items = array();
	var $header = 'h3';
	
	public function __construct($id=""){
		$this->id = $id;
	}
	//IMPLEMENTED ABSTRACT METHOD
	public function renderHead()
	{
		return "$('#".$this->id."').accordion({
					autoHeight		: ".$this->autoHeight.",
					header 			: '".$this->header."'
				});";
	}
	public function renderBody()
	{
		$output = "<div id=\"".$this->id."\">";
		foreach($this->items as $item){
			$output .= "<div>";
			$output .= "<".$this->header."><a href=\"#\">".$item[0]."</a></".$this->header.">\n";
			$output .= "<div>".$item[1]."</div>\n";
			$output .= "</div>";
		}
		$output .= "</div>";
		return $output;
	}
	//PUBLIC ORDER
	public function addItem($header,$body)
	{
		array_push($this->items,array($header,$body));
	}
}